#ifndef __DISCOVERY_H
#define __DISCOVERY_H

#include "xlowpan.h"

#define DSP_DISCOVERY 'D'
#define BROADCAST_DISC 1
#define BROADCAST_DISC_RESPONSE 2
#define BROADCAST_ASSOC 3
#define BROADCAST_ASSOC_RESPONSE 4
#define BROADCAST_ASSOC_ACCEPT 5

#define DISC_MODE_IDLE 0
#define DISC_MODE_ASSOC_WAITING 1
#define DISC_MODE_DISC_WAITING 2

#define TRANSMIT_ADDR 1
#define TRANSMIT_DATA 2

//the number of discovered devices to store
#define DISC_BUFFER_SIZE 8

void discovery_set_data(char* data);
void discovery_set_cdata(const char* data);

char* discovery_get_data(unsigned char i);

void discovery_find_basestation(void);

void discovery_find_basestation_beacon(void);

struct xlowpan_addr64* discovery_find_basestation_end(void);

void discovery_start(void);

void discovery_beacon(void);

int discovery_end(struct xlowpan_addr64** addresses);

void discovery_set_mode_basestation(unsigned char bs);
void discovery_set_accept(void (*X)(struct xlowpan_addr64*));

struct xlowpan_addr64* discovery_get_basestation(void);

void discovery_decodepacket(struct xlowpan_addr64* from, unsigned char* data, unsigned char hops, unsigned char length);

void discovery_init(void);
void discovery_save(void);

#endif